﻿using MESPro.Controls;
using SqlSugar;
using System;
using System.ComponentModel;
using System.Xml.Linq;

namespace MESPro.Models
{
    /// <summary>
    /// 数据库基类,有Id,有Name,有创建人,修改人,
    /// </summary>
    //[DefaultProperty(nameof(Id))]
    public class EntityBaseIdNameCreat : EntityBaseIdName
    {

        #region 属性

        /// <summary>
        /// 对应的图标,实际为图标路径
        /// </summary>
        [DisplayName("\t\t\t\t\t\t\t\t图标"), ReadOnly(false), Description("图标设置"), Category("\t\t\t\t\t\t\t\t属性配置"), Browsable(true)]
        [Editor(typeof(PropertyReturnFileName),
typeof(System.Drawing.Design.UITypeEditor))]
        public string? ImageKey { get; set; } = "RM.ico";


        /// <summary>
        /// 创建人Id
        /// </summary>
        [SugarColumn(ColumnDescription = "创建人ID")]
        [DisplayName("创建人Id"), ReadOnly(false), Description("创建人Id"), Category("\t\t\t\t\t\t\t\t属性配置"), Browsable(false)]
        public int CreateUserId { get; set; }



        /// <summary>
        /// 创建时间
        /// </summary>
        [SugarColumn(ColumnDescription = "创建时间", IsNullable = true)]
        [DisplayName("创建时间"), ReadOnly(false), Description("创建事件"), Category("\t\t\t\t\t\t\t\t属性配置"), Browsable(false)]
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 修改人Id
        /// </summary>
        [DisplayName("修改人Id"), ReadOnly(false), Description("修改人Id"), Category("\t\t\t\t\t\t\t\t属性配置"), Browsable(false)]
        public int ModifyUserId { get; set; }



        /// <summary>
        /// 修改时间
        /// </summary>
        [DisplayName("修改时间"), ReadOnly(false), Description("修改时间"), Category("\t\t\t\t\t\t\t\t属性配置"), Browsable(false)]
        [SugarColumn(IsNullable = true)]
        public DateTime ModifyTime { get; set; }

        #endregion 属性

        //ModifyUserId

    }

    /// <summary>
    /// 
    /// </summary>
    public class DbControlBase : EntityBaseIdNameCreat
    {

    }
    /// <summary>
    /// 表基类,只有Id属性
    /// </summary>
    public class EntityBaseId
    {

        #region 属性

        /// <summary>
        /// 自增主键
        /// </summary>
        [SugarColumn(ColumnDescription = "主键", IsPrimaryKey = true, IsIdentity = true)]
        [DisplayName("\t\t\t\t\t\t\t\t\t\t主键Id"), ReadOnly(true), Description("主键Id"), Category("\t\t\t\t\t\t\t\t属性配置"), Browsable(true)]
        public int Id { get; set; }

        #endregion 属性

    }
    /// <summary>
    /// 表基类,有Id属性和Name属性
    /// </summary>
    public class EntityBaseIdName : EntityBaseId
    {
        private string? disName;

        #region 字段



        #endregion 字段

        #region 属性

        /// <summary>
        /// 用于界面显示的名字,唯一约束,ufo 似乎可以省略,只有在control时候才有用
        /// </summary>
        [SugarColumn(Length = 150, IsNullable = true)]
        [DisplayName("\t\t\t\t\t\t\t\t\t名字"), Description("用于界面显示的名字,唯一约束"), Category("\t\t\t\t\t\t\t\t属性配置")]
        public string? DisName
        {
            get
            {
                return DisLanguage.GetDisplayName();
            }

            set
            {
                disName = value;
                DisLanguage.SetLanguage(App.User.Language, disName);
            }
        }
        /// <summary>
        /// 这个模块对应的各种语言
        /// </summary>
        [SugarColumn(IsJson = true, IsNullable = true)]
        [DisplayName("显示语言设置"), ReadOnly(false), Description("显示语言设置"), Category("\t\t\t\t\t\t\t\t属性配置")]
        [TypeConverter(typeof(ExpandableObjectConverter))]
        public DisLanguage DisLanguage { get; set; } = new DisLanguage();

        #endregion 属性

    }
}